package com.zhxh.nzpos.setting;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.zhxh.nzpos.R;

/**
 * 系统设置界面
 * 
 * @author wangzt
 *
 */
public class SystemSettingActivity extends Activity {
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting_system);
        initViews();
    }
	
	private void initViews() {
		final EditText postIdET = (EditText) findViewById(R.id.pos_id_et);
		final EditText shopNameET = (EditText) findViewById(R.id.shop_name_et);
		final EditText serverIpET = (EditText) findViewById(R.id.server_ip_et);
		final EditText serverPortET = (EditText) findViewById(R.id.server_port_et);
		ImageView okBtn = (ImageView) findViewById(R.id.system_setting_ok_btn);
		okBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				// TODO初始化商店信息并保存
				if( postIdET.getText().toString().length() == 0 ){
					postIdET.setError( "机号不能为空" );
					return;
					
				}
				if( shopNameET.getText().toString().length() == 0 ){
					shopNameET.setError( "商店名称不能为空" );
					return;
					
				}
				if( serverIpET.getText().toString().length() == 0 ){
					serverIpET.setError( "服务器地址不能为空" );
					return;
					
				}
				if( serverPortET.getText().toString().length() == 0 ){
					serverPortET.setError( "端口不能为空" );
					return;
					
				}
				Toast.makeText(getApplicationContext(), "系统设置成功", Toast.LENGTH_SHORT).show();
				finish();
			}
		});
		ImageView cancelBtn = (ImageView) findViewById(R.id.system_setting_cancel_btn);
		cancelBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				finish();
			}
		});
	}
}
